Be sure that you have a debugger installed on the machine that you run these on, because any errors cause calls to the debugger. If you don't have a debugger, you will get an "Unimplemented A-Trap" if any sort of an error occurs. You may use Macsbug, Jasik's Debugger, TMON, etc.
If you have a previous version of Writeswell Jr., you must trash the Writeswell Jr. Preferences file. It is in the Preferences folder.
The source is included to the text editor. We plan to distribute the source free of charge, but please don't distribute this yet. I want to add some more stuff, and fix some bugs.
Double-click "IAC Spell Test". Then drag "testtext" onto the "Writeswell Jr." icon. Select "Get New Batch Service" from Writeswell Jr.'s menu. Select the speller in the browser. This adds "Check Spelling with IAC Spell Test" to the Services Menu. Then you can use this menu item to check spelling. After this initial setup the menu item will launch the speller whether it is running in the background or not, making it invisible to the user that the speller is not a built-in menu item.
Position the speller's window so you can see the text in Writeswell Jr., and hit skip or replace as you like.
The technique that I use for handling Apple Events is the "Object First Approach" described by Richard Clark in the May, 1992 issue of d e v e l o p, in the article "Apple Event Objects and You."
I call this an "inverted" handling method myself in the code. I resolve the object specifier first (in a wildcard handler), and then pass the token to a dispatcher that calls the functions to actually do the event. The "normal" way to do it is to install a handler for each event, resolve the object specifier, and then call code to do the event for each type. The object first approach allows new data types to be added in a simpler manner.
I highly recommend reading Richard's article while studying this code.
The Object Support Library on this disk is converted from the MPW OSL using the ThinkC "oConv" utility. If you want to do the conversion yourself, use the vocabulary file in the Apple Libraries folder. If you convert without using the vocabulary file, the OSL function names will all be uppercase.
Enjoy!
Mike Crawford
Working Software, Inc.
AppleLink D1620
Compuserve 76004,2072
Change History:
1.0
Implemented all the menu items.
Fixed up the scroll bars some. They're still kind of funky.
The background highlighting code will also scroll the selection into view if it is off the window.
I wrote code to check the style menu items, but they don't seem to work. This appears to me to be a bug in the System, in the TextEdit TEContinuousStyle function. I would appreciate any suggestions that anyone has on how to fix it.
1.0d14
Filled out the file menu with Save, Print, etc. Not all of these are implemented yet.
I removed the Check Selection menu item, and the menu items for interactive checking from the Services menu. These will return in a future release. We're getting ready to ship WWJr, and will ship it without the interactive code. We do want to support it though, and hope to do so in the future.
1.0d13
I fixed a bug in which the speller would fail to read all of the text in the second and subsequent blocks of a multiple block document.
1.0d12
I fixed a bug in Writeswell Jr. which would occasionally cause a crash when start up a session. DoBatchTableCheck in TableCheck.c disposed of a descriptor that had not been allocated.
Writeswell Jr. now supports the Count Elements event. A speller may send Count Elements to find out how many elements are in the table of object specifiers used with the "Send table specifier" option. One can also count the number of text blocks in a document window. (The result will be 1 in both cases). The Count Elements event has been added to the AETE resource so you can send it with AppleScript.
It is not strictly necessary to support Count Elements for Word Services. The speller can tell when it is done by trying, and failing, to get a new block. You should support Count Elements if you can; the only reason you might not want to is that it may require a lot of time to actually count the elements. This might be the case if the elements are all the records in a database that match a particular search pattern, for example.
A bug has been fixed in the speller which prevented it from checking more than one text block when "Send table specifier" is selected.
A bug has been fixed which made the speller always replace the same range of characters if background highlighting was not supported in the word processor.
1.0d11
I now launch the speller by sending an Open Selection event to the Finder, rather than by calling LaunchApplication. This has the advantage of displaying zoom rects, and greying out the icon of the speller to show that it is running. (If one uses LaunchApplication, the Finder does not know that the speller has been launched).
I had tried this before, but it did not work because one of the parameters was wrong. Instead of sending an alias descriptor for the speller, one must send an AEList of alias descriptors.
Support has been added for the "listHead" method of spellchecking. Writeswell Jr. will send an object specifier to a table of text specifiers of you select "Send Table Specifier" in the Options dialog. The speller will respond to this by sending Get Data events to get object specifier objects from the table, and use each object specifier in turn to do spellchecking. This is most useful for documents that contain large numbers of separate text cells.
1.0d10
I fixed a bug in which the formRange specifiers sent by the speller were one character too long. This effectively made 0 be the last character in the text field, rather than -1. The bug was compensated for in Writeswell Jr., so I didn't notice either bug.
This makes Writeswell Jr. and IAC Spell Test incompatible with previous versions.
1.0d9
I implemented the "Remove Services" menu item. Now you don't have to throw away the preferences file to remove menu items from the Services menu.
1.0d8
I added an AETE resource to Writeswell Jr. to support AppleScript. The AppleScript support is still pretty rudimentary, but will grow over time.
1.0d7
I changed the parameter of the batch event to require a list of object specifiers. This is meant to simplify the use of the "listHead" method of getting the specifiers. Even if you just want a single block of text spellchecked, you must send a list with a single element.
This makes Writeswell Jr. and IAC Spell Test incompatible with previous versions.
1.0d6
Added the Font and Style menus in Writeswell Jr., and changed the TextEdit record to use Styled Textedit.
1.0d5
Changed the name of the text editor to "Writeswell Jr."
Changed services menu to get menu strings from the speller. Selecting the speller's item will launch the speller if it is not already running.
Added the preferences file.
Made the window resizable and scrollable.
Made the speller respond immediately to batch events so it can respond when launched by the editor. Before, it needed a couple null events before it would start responding to batch events.
1.0d3
Changed the icons
Fixed some bugs in the speller that would cause out of memory errors (these were in the speller code itself, and not the IAC stuff)